<template>
    <view class="tea-container">

        <view style="display: flex; justify-content: space-between; align-items: center;padding:0 20rpx;">
            <text style="font-size: 32rpx;font-weight: bold;font-family: PingFang SC, PingFang SC;">养生茶</text>
            <view style="color: #6E6E6E; font-size: 24rpx;">
            <text >查看全部</text>
            <text>></text>
            </view>

        </view>


        <view style="display: flex;justify-content: center;align-content: center;">
            <NavBar :navItems="myNavItems" :text_padding="30" :fontSize="30" :dynamicHeight="8" :indicatorWidth="64"
            @item-selected="onItemSelected" />
        </view>
        <view class="tea-fack_tea">
            <!-- 顶部图片部分 -->
            <view class="tea-top-image">
                <image src="https://safood.supplyocta.com/Uploads/tempImage/2024-08-13/66bb43ebc7eab4469.png" mode="aspectFill"></image>
            </view>

            <!-- 底部产品列表 -->
            <view class="tea-product-list">
                <view class="tea-product-item" v-for="(item, index) in products" :key="index">
                    <image :src="item.image" mode="aspectFit" class="tea-product-image"></image>
                    <view class="tea-product-info">
                        <text class="tea-product-name">{{ item.name }}</text>
                        <view class="tea-product-description">{{ item.description }}</view>
                    </view>
                </view>
            </view> 
        </view>
    </view>
</template>

<script>
import NavBar from './xztdemoNavBar.vue'
export default {
    components: {
        NavBar
    },
    data() {
        return {
            products: [
                { name: '蒲公英玉米须茶', description: '抗痛消炎', image: 'https://safood.supplyocta.com/Uploads/tempImage/2024-08-14/66bc1ad7813025301.png' },
                { name: '火麻仁茶', description: '润肺养胃', image: 'https://safood.supplyocta.com/Uploads/tempImage/2024-08-14/66bc1ad7813025301.png' },
                { name: '酸枣仁茶茶', description: '安神助眠', image: 'https://safood.supplyocta.com/Uploads/tempImage/2024-08-14/66bc1ad7813025301.png' }
            ],
            myNavItems: ['调理身体', '滋补肝肾', '改善体质', '益精明目',],

        }
    },

    methods: {
        onItemSelected(index) {
            console.log('Selected item index:', index)
            // 处理选中项的逻辑
        }
    }
}
</script>

<style>
.tea-container {
    padding: 20rpx;
}

.tea-fack_tea {
    border: 1px solid grey;
    border-radius: 10rpx;
    overflow: hidden;
    position: relative;
    padding-bottom: 220rpx; /* 为底部产品列表留出空间 */
}

.tea-top-image {
    width: 100%;
    height: 300rpx;
}

.tea-top-image image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tea-product-list {
    display: flex;
    justify-content: space-around;
    position: absolute;
    left: 20rpx;
    right: 20rpx;
    bottom: 20rpx;
}

.tea-product-item {
    width: 30%;
    background-color: #FFFFFF;
    border-radius: 10rpx;
    overflow: hidden;
    box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.1);
}

.tea-product-image {
    width: 100%;
    height: 180rpx;
}

.tea-product-info {
    padding: 10rpx;
    display: flex;
    flex-direction: column;
    background-color: #F2F2F2;
}

.tea-product-name {
    font-size: 24rpx;
    font-weight: bold;
    color: #333;
}

.tea-product-description {
    font-size: 20rpx;
    color: #666;
    margin-top: 5rpx;
}
</style>
